package crp.core.workflow.app;

import crp.core.workflow.domain.services.WorkflowEngine;
import crp.core.workflow.domain.services.WorkflowCommandCreator;
import crp.core.workflow.domain.services.WorkflowInstanceSearcher;
import crp.core.workflow.domain.services.WorkflowModelSearcher;
import crp.core.workflow.domain.services.WorkflowTaskSearcher;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;

@ApplicationScoped
public class WorkflowService {
    private final Instance<WorkflowEngine> engines;
    private final Instance<WorkflowInstanceSearcher> instanceSearchers;
    private final Instance<WorkflowModelSearcher> modelSearchers;
    private final Instance<WorkflowCommandCreator> commandCreators;
    private final Instance<WorkflowTaskSearcher> taskSearchers;

    @Inject
    public WorkflowService(Instance<WorkflowEngine> engines,
                           Instance<WorkflowInstanceSearcher> instanceSearchers,
                           Instance<WorkflowModelSearcher> modelSearchers,
                           Instance<WorkflowCommandCreator> commandCreators,
                           Instance<WorkflowTaskSearcher> taskSearchers) {
        this.engines = engines;
        this.instanceSearchers = instanceSearchers;
        this.modelSearchers = modelSearchers;
        this.commandCreators = commandCreators;
        this.taskSearchers = taskSearchers;
    }

    public WorkflowEngine engine() {
        return engines.get();
    }

    public WorkflowCommandCreator commandCreator() {
        return commandCreators.get();
    }

    public WorkflowInstanceSearcher instanceSearcher() {
        return instanceSearchers.get();
    }

    public WorkflowModelSearcher modelSearcher() {
        return modelSearchers.get();
    }

    public WorkflowTaskSearcher taskSearcher() {
        return taskSearchers.get();
    }
}
